package vn.com.bookstore.adapter;

import vn.com.bookstore.BookStoreApplication;
import vn.com.bookstore.fragment.ListBookFragment;
import vn.com.bookstore.fragment.StoreFragment;
import android.content.Context;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

public class MyPagerAdapter extends FragmentPagerAdapter {
	Fragment mStoreFragment;
	Fragment mListBookFragment;
	public MyPagerAdapter(Context context, FragmentManager fm) {
		super(fm);
		this.context = context;
		
		mStoreFragment = new StoreFragment();
		mListBookFragment = new ListBookFragment();
	}

	Context context;

	@Override
	public int getCount() {
		return 2;
	}

	@Override
	public Fragment getItem(int position) {
		Fragment fragment = null;
		switch (position) {
		case 0:
			return mStoreFragment;
		case 1:
			return mListBookFragment;
		default:
			break;
		}
		return fragment;
	}

	
	@Override
	public float getPageWidth(int position) {
		switch (position) {
		case 0:
			if(BookStoreApplication.isTablet(context)){
				return 0.4f;
			}else
				return 0.6f;
		case 1:
			if(BookStoreApplication.isTablet(context)){
				return 0.6f;
			}else{
				return 1.0f;
			}
		}
		return 1f;
	}
}